package com.xinzhilibrary.dao;

import com.xinzhilibrary.model.GoodsInfo;
import com.xinzhilibrary.model.OrderInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.annotation.Order;

import java.util.ArrayList;

@Mapper
public interface IGoodsInfoDao {
    ArrayList<GoodsInfo> selectAllGoods(@Param("startNum") int startNum,
                                        @Param("lineNumber") int lineNumber,
                                        @Param("goodsName") String goodsName,
                                        @Param("goodsType") int goodsType );

    int updateGoods(@Param("goodsInventory")int goodsInventory,@Param("goodsName")  String goodsName);//购买时修改商品库存接口

    //新增订单
    //订单(订单ID/订单商品名/订单总价格/订单状态/订单对应的用户名) 订单状态 0 未结算/ 1 已结算
    int insertOrder(OrderInfo orderInfo);

    OrderInfo checkGoodsInfo(@Param("orderGoodsName") String orderGoodsName,
                             @Param("orderGoodsUserId") int orderGoodsUserId);

    int updateOrderInfo(@Param("orderGoodsName") String orderGoodsName,
                        @Param("orderGoodsNumber") int orderGoodsNumber,
                        @Param("orderValue") double orderValue);//购买时修改商品库存接口

    ArrayList<OrderInfo> selectOrder(@Param("orderGoodsUserId") int orderGoodsUserId);

    ArrayList<OrderInfo> selectAllOrder(@Param("orderGoodsUserId") int orderGoodsUserId);
    //新增商品
    int insertGoods(GoodsInfo goodsInfo);

    //用户选择对应的订单，单独结算(订单初始状态为0，结算状态为1 )
    int updateUserOrderStatus(@Param("orderGoodsName") String orderGoodsName,
                          @Param("orderGoodsUserId") int orderGoodsUserId);
    //结算订单的方法为：1.将订单状态设置为1，2.将订单价格从用户余额中扣减，3.将订单价格加到管理员账户中
    //删除购物车订单
    int deleteOrder(@Param("orderGoodsName") String orderGoodsName,
                     @Param("orderGoodsUserId") int orderGoodsUserId);
    //用户同时结算所有订单
    //所有结算操作都要扣除用户余额，并将扣除的金额添加到管理员账户
    int updateOrderStatus(@Param("orderGoodsUserId") int orderGoodsUserId);
    //用户充值
    int updateUserMoney (@Param("userMoney") double userMoney,//充值金额
                         @Param("userId") String userName);
    double selectUserMoney(@Param("userId") int userId);
}
